-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[asan] Pass -falign-functions=16 when building on Windows #154694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Win/ASan relies on the runtime's functions being 16-byte aligned so it can intercept them with hotpatching. This used to be true (but not guaranteed) until llvm#149444. Pass the flag to explicitly request enough alignment.
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Hans Wennborg (zmodem) ChangesWin/ASan relies on the runtime's functions being 16-byte aligned so it can intercept them with hotpatching. This used to be true (but not guaranteed) until #149444. Pass the flag to explicitly request enough alignment. Full diff: https://github.com/llvm/llvm-project/pull/154694.diff 1 Files Affected:
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index d1d229e3e6d40..3850d3ce8a9d7 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -106,6 +106,14 @@ if(MSVC)
endif()
set(ASAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+# Win/ASan relies on the runtime having 16-byte aligned functions for
+# hotpatching. See https://github.com/llvm/llvm-project/pull/149444
+if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
+ list(APPEND ASAN_CFLAGS /clang:-falign-functions=16)
+ endif()
+endif()
+
append_list_if(MSVC /Zl ASAN_CFLAGS)
set(ASAN_COMMON_DEFINITIONS "")
|
This will only work if the function following
|
I think it would work in practice, but |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/14280 Here is the relevant piece of the build log for the reference
|
Win/ASan relies on the runtime's functions being 16-byte aligned so it can intercept them with hotpatching. This used to be true (but not guaranteed) until #149444.
Pass the flag to explicitly request enough alignment.